# """
# This is the interface that allows for creating nested lists.
# You should not implement it, or speculate about its implementation
# """
class NestedInteger(object):
   def __init__(self, value=None):
       """
        If value is not specified, initializes an empty list.
        Otherwise initializes a single integer equal to value.
       """
       self.value = value if value is not None else [] # 如果value不为None，则赋值给self.value，否则赋值给[]

   def isInteger(self):
       """
       @return True if this NestedInteger holds a single integer, rather than a nested list.
       :rtype bool
       """
       return isinstance(self.value, int) # 如果self.value是int，则返回True，否则返回False

   def add(self, elem):
       """
       Set this NestedInteger to hold a nested list and adds a nested integer elem to it.
       :rtype void
       """
       self.value.append(elem) # 将elem添加到self.value中

   def setInteger(self, value):
       """
       Set this NestedInteger to hold a single integer equal to value.
       :rtype void
       """
       self.value = value # 将value赋值给self.value

   def getInteger(self):
       """
       @return the single integer that this NestedInteger holds, if it holds a single integer
       Return None if this NestedInteger holds a nested list
       :rtype int
       """
       return self.value # 如果self.value是int，则返回self.value，否则返回None

   def getList(self):
       """
       @return the nested list that this NestedInteger holds, if it holds a nested list
       Return None if this NestedInteger holds a single integer
       :rtype List[NestedInteger]
       """
       return self.value # 如果self.value是list，则返回self.value，否则返回None

# 方法一：深度优先搜索
class Solution1:
    def deserialize(self, s: str) -> NestedInteger:
        index = 0

        def dfs() -> NestedInteger:
            nonlocal index
            if s[index] == '[':
                index += 1
                ni = NestedInteger()
                while s[index] != ']':
                    ni.add(dfs())
                    if s[index] == ',':
                        index += 1
                index += 1
                return ni
            else:
                negative = False
                if s[index] == '-':
                    negative = True
                    index += 1
                num = 0
                while index < len(s) and s[index].isdigit():
                    num *= 10
                    num += int(s[index])
                    index += 1
                if negative:
                    num = -num
                return NestedInteger(num)

        return dfs()

# 方法二：栈
class Solution:
    def deserialize(self, s: str) -> NestedInteger:
        if s[0] != '[':
            return NestedInteger(int(s))
        stack, num, negative = [], 0, False
        for i, c in enumerate(s):
            if c == '-':
                negative = True
            elif c.isdigit():
                num = num * 10 + int(c)
            elif c == '[':
                stack.append(NestedInteger())
            elif c in ',]':
                if s[i-1].isdigit():
                    if negative:
                        num = -num
                    stack[-1].add(NestedInteger(num))
                num, negative = 0, False
                if c == ']' and len(stack) > 1:
                    stack[-2].add(stack.pop())
        return stack.pop()


# 调用 NestedIterator 的 next 和 hasNext 函数
def stringToString(input):
    # return input[1:-1].decode('string_escape')
    return input[1:-1]


def intToString(input):
    if input is None:
        input = 0
    return str(input)


def nestedIntegerToString(nestedInteger):
    if nestedInteger.isInteger():
        return intToString(nestedInteger.getInteger())
    else:
        serializedNestedIntegers = []
        for ni in nestedInteger.getList():
            serializedNestedInteger = nestedIntegerToString(ni)
            serializedNestedIntegers.append(serializedNestedInteger)
        return "[{}]".format(', '.join(serializedNestedIntegers))


def main():
    import sys
    def readlines():
        for line in sys.stdin:
            yield line.strip('\n')

    lines = readlines()
    while True:
        try:
            line = next(lines)
            s = stringToString(line)

            ret = Solution().deserialize(s)

            out = nestedIntegerToString(ret)
            print(out)
        except StopIteration:
            break


if __name__ == '__main__':
    main()